package com.twu.biblioteca;

import java.util.ArrayList;

public class MovieList {
    private ArrayList<MovieDetail> movieList;

    public MovieList(){
        movieList = new ArrayList<MovieDetail>();
        this.initializeBooks();
    }

    private void initializeBooks(){
        movieList.add(new MovieDetail("The Godfather", "Francis Ford Coppola", "1972", 9));
        movieList.add(new MovieDetail("The Dark Knight", "Christopher Nolan", "2008", 0));

    }

    public MovieDetail searchMovie(String movieName) throws Exception {
        for(MovieDetail movie : movieList)
            if(movie.getName().equals(movieName))
                return movie;

        throw new Exception();

    }

    public void displayMovies() {
        Console console = new Console();
        int id = 1;

        console.write("ID      Name               Director             Year    Rating\n");

        for(MovieDetail movie : movieList) {
            if(movie.getCheckedOut() == false)
                console.write(id + "   " + movie.toString() + "\n");
            id++;

        }
    }
}
